<!--添加角色-->
<div class="dialog_content">
    <form id="info_form" name="info_form" action="{:u('admin_role/add')}" method="post">
    <table width="100%" class="table_form">
        <tr>
            <th width="80">{:L('role_name')} :</th>
            <td><input type="text" name="name" id="name" class="input-text"></td>
        </tr>
        <tr>
            <th>{:L('region_level')} :</th>
            <td>
                <label><input type="radio" name="regionLevel" value="0" />{:L('region_level0')}</label>&nbsp;&nbsp;
                <label><input type="radio" name="regionLevel" value="1" />{:L('region_level1')}</label>&nbsp;&nbsp;
                <label><input type="radio" name="regionLevel" value="2" />{:L('region_level2')}</label>&nbsp;&nbsp;
                <label><input type="radio" name="regionLevel" value="3" />{:L('region_level3')}</label>
            </td>
        </tr>  
        <tr>
            <th width="80">上级角色ID :</th>
            <td>
                <select name="pid">
                    <option value="">{:L('please_select')}</option>
                    <volist name="roleList" id="item">
                        <option value="{$key}">{$item}</option>
                    </volist>
                </select>
            </td>
        </tr>              
        <tr>
            <th>{:L('role_desc')} :</th>
            <td><textarea name="remark" id="remark" cols="40" rows="3"></textarea></td>
        </tr>     
         
        <tr>
            <th>角色头像 :</th>
            <td>
            	<input type="text" name="img" id="J_img" class="input-text fl mr10" size="30">
            	<div id="J_upload_img" class="upload_btn"><span>{:L('upload')}</span></div>
            </td>
        </tr>
          
        <tr>
            <th>{:L('enabled')} :</th>
            <td>
                <input type="radio" name="status" class="radio_style" value="1" checked="checked"> &nbsp;{:L('yes')}&nbsp;&nbsp;&nbsp;
                <input type="radio" name="status" class="radio_style" value="0"> &nbsp;{:L('no')}
            </td>
        </tr>
        
        <!--tr>
            <th>是否需要选择客户 :</th>
            <td>
                <input type="radio" name="selectCustomer" class="radio_style" value="1" checked="checked"> &nbsp;{:L('yes')}&nbsp;&nbsp;&nbsp;
                <input type="radio" name="selectCustomer" class="radio_style" value="0"> &nbsp;{:L('no')}
            </td>
        </tr-->        
        
    </table>
    </form>
</div>
<script src="__STATIC__/js/fileuploader.js"></script>
<script>
$(function(){
    $.formValidator.initConfig({formid:"info_form",autotip:true});
    $("#name").formValidator({ onshow:lang.please_input+lang.role_name, onfocus:lang.please_input+lang.role_name, oncorrect:lang.input_right}).inputValidator({ min:1, onerror:lang.please_input+lang.role_name});

    $('#info_form').ajaxForm({success:complate,dataType:'json'});
    function complate(result){
        if(result.status == 1){
            $.dialog.get(result.dialog).close();
            $.pinphp.tip({content:result.msg});
            window.location.reload();
        } else {
            $.pinphp.tip({content:result.msg, icon:'alert'});
        }
    }
    
	//上传图片
    var uploader = new qq.FileUploaderBasic({
    	allowedExtensions: ['jpg','gif','jpeg','png','bmp','pdg'],
        button: document.getElementById('J_upload_img'),
        multiple: true,
        maxConnections:4,
        action: "{:U('admin_role/ajax_upload_img')}",
        inputName: 'img',
        forceMultipart: true, //用$_FILES
        messages: {
        	typeError: lang.upload_type_error,
        	sizeError: lang.upload_size_error,
        	minSizeError: lang.upload_minsize_error,
        	emptyError: lang.upload_empty_error,
        	noFilesError: lang.upload_nofile_error,
        	onLeave: lang.upload_onLeave
        },
        showMessage: function(message){
        	$.pinphp.tip({content:message, icon:'error'});
        },
        onSubmit: function(id, fileName){
        	$('#J_upload_img').addClass('btn_disabled').find('span').text(lang.uploading);
        },
        onComplete: function(id, fileName, result){
        	$('#J_upload_img').removeClass('btn_disabled').find('span').text(lang.upload);
            if(result.status == '1'){
        		$('#J_img').val(result.data);
        	} else {
        		$.pinphp.tip({content:result.msg, icon:'error'});
        	}
        }
    });    
});
</script>